package com.itheima.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.mapper.OperateLogMapper;
import com.itheima.pojo.OperateLog;
import com.itheima.pojo.PageResult;
import com.itheima.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LogServiceImpl extends ServiceImpl<OperateLogMapper, OperateLog> implements LogService {
    @Autowired
    private OperateLogMapper operateLogMapper;

    @Override
    public PageResult page(Integer page, Integer pageSize) {
        // 使用 MyBatis-Plus 的分页查询
        IPage<OperateLog> iPage = new Page<>(page, pageSize);
        // 执行查询并填充分页结果
        Page page1 = (Page) page(iPage, null);
        // 返回正确的分页结果
        return new PageResult<>(page1.getTotal(), page1.getRecords());
    }
}
